package com.codemonkey.lq.qd.facotry.config.event;

import com.codemonkey.lq.qd.facotry.config.ExecuteEventListener;
import com.codemonkey.lq.qd.facotry.config.ExecutionEvent;

public class GenericExecuteEventListenerAdapter implements SmartExecuteEventListener {

	private final ExecuteEventListener<ExecutionEvent> delegate;
	
	public GenericExecuteEventListenerAdapter(ExecuteEventListener<ExecutionEvent> delegate) {
		super();
		this.delegate = delegate;
	}

	@Override
	public boolean supportsEventType(Class<? extends ExecutionEvent> eventType) {		
		//TODO  我们没有Spring中的GenericTypeResolver来检索事件类型,就像在GenericApplicationListenerAdapter中一样
		//        这里的泛型类型的问题可以参考下Mybatis里的TypeReference类,有专门的测试类TypeReference_Tests  2017-03-29
		//        核心逻辑在TypeReference类的getSuperclassTypeParameter方法中
		return false;
	}

	@Override
	public boolean supportsSourceType(Class<?> sourceType) {		
		return true;
	}

	@Override
	public void onExecuteFinished(ExecutionEvent event) {
		this.delegate.onExecuteFinished(event);
	}

}
